<include file="Layout/header" />
<body>
<div class="breadcrumbs" id="breadcrumbs"> 
  <script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>
  <ul class="breadcrumb">
    <li> <i class="icon-home home-icon"></i> <a href="{:U('Admin/Index/welcome')}">首页</a> </li>
    <li class="active">自定义导航</li>
  </ul>
</div>
<div class="page-content">
  <div class="page-header">
    <h1> 系统设置 <small> <i class="icon-double-angle-right"></i> 自定义导航 </small> </h1>
  </div>
  <!-- /.page-header -->
  
  <div class="row">
    <div class="col-sm-3">
      <div class="widget-box">
        <div class="widget-header widget-header-flat">
          <h4 class="smaller"> <i class="icon-quote-left smaller-80"></i>添加导航</h4>
        </div>
        <div class="widget-body">
          <div class="widget-main">
            <form class="form-horizontal" action="{:U('Admin/Setting/nav')}" id="validation-form" method="post" enctype="multipart/form-data">
              <input type="hidden" name="nav_id" value="{$nav_id}"/>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="nav_title">导航标题:</label>
                <div class="col-xs-12 col-sm-9">
                  <div class="clearfix">
                    <input type="text" id="nav_title" name="nav_title" value="{$nav.nav_title}" class="col-xs-12 col-sm-5" />
                  </div>
                </div>
              </div>
              <div class="form-group">
              <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="nav_location">导航位置</label>
              <div class="col-xs-12 col-sm-9">
              <div class="clearfix">
                <select class="input-medium" id="nav_location" name="nav_location">
                  <option value="">------------------</option>
                  <option value="0" <if condition="$nav.nav_location eq 0"> selected="selected"</if>>顶部</option>
                  <option value="1" <if condition="$nav.nav_location eq 1"> selected="selected"</if>>中间</option>
                  <option value="2" <if condition="$nav.nav_location eq 2"> selected="selected"</if>>底部</option>
                   
                </select>
              </div>
              </div>
              </div>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="nav_sort">排序:</label>
                <div class="col-xs-12 col-sm-9">
                  <div class="clearfix">
                    <input type="text" id="nav_sort" name="nav_sort" value="{$nav.nav_sort}" class="col-xs-12 col-sm-5" />
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="nav_url">链接地址:</label>
                <div class="col-xs-12 col-sm-9">
                  <div class="clearfix">
                    <input type="text" id="nav_url" name="nav_url" value="{$nav.nav_url}" class="col-xs-12 col-sm-5" />
                  </div>
                </div>
              </div>
              <div class="space-2"></div>
                      <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-3 no-padding-right">是否以新窗口打开</label>
                        <div class="col-xs-12 col-sm-9">
                          <div>
                            <label class="blue">
                              <input name="nav_new_open" value="0" type="radio" class="ace" <if condition="$nav.nav_new_open eq 0">checked</if> />
                              <span class="lbl"> 否</span> </label>
                          </div>
                          <div>
                            <label class="blue">
                              <input name="nav_new_open" value="1" type="radio" class="ace" <if condition="$nav.nav_new_open eq 1">checked</if>/>
                              <span class="lbl"> 是</span> </label>
                          </div>
                        </div>
                      </div>
                      
                      
                      
                <div class="space-2"></div>
                      <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-3 no-padding-right">是否显示</label>
                        <div class="col-xs-12 col-sm-9">
                          <div>
                            <label class="blue">
                              <input name="nav_is_close" value="0" type="radio" class="ace" <if condition="$nav.nav_is_close eq 0">checked</if> />
                              <span class="lbl"> 否</span> </label>
                          </div>
                          <div>
                            <label class="blue">
                              <input name="nav_is_close" value="1" type="radio" class="ace" <if condition="$nav.nav_is_close eq 1">checked</if>/>
                              <span class="lbl"> 是</span> </label>
                          </div>
                        </div>
                      </div>      
              <div class="hr hr-dotted"></div>
              <div class="form-group">
                <label class="control-label col-xs-12 col-sm-3 no-padding-right"></label>
                <div class="col-xs-12 col-sm-9"><input class="btn btn-primary radius" type="submit" id="submitBtn" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"></div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-9">
      <div class="row">
        <div class="col-xs-12">
          <div class="widget-box">
            <div class="widget-header widget-header-flat">
              <h4 class="smaller">导航列表</h4>
            </div>
            <div class="widget-body">
              <div class="widget-main">
                <div class="tabbable">
                  <ul class="nav nav-tabs" id="myTab">
                    <li <if condition="$nav.nav_location eq 0"> class="active" <else />class=""</if>> <a data-toggle="tab" href="#top"> 顶部导航 </a> </li>
                    <li <if condition="$nav.nav_location eq 1"> class="active" <else />class=""</if>> <a data-toggle="tab" href="#center"> 中间导航 </a> </li>
                    <li <if condition="$nav.nav_location eq 2"> class="active" <else />class=""</if>> <a data-toggle="tab"  href="#down"> 底部导航 </a> </li>
                  </ul>
                  <div class="tab-content">
                    <div id="top" class="tab-pane <if condition="$nav.nav_location eq 0"> active</if>">
                      <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                        <thead>
                          <tr>
                            <th>导航名称</th>
                            <th class="hidden-480">位置</th>
                            <th class="hidden-480">排序</th>
                            <th>是否显示</th>
                            <th>是否新窗口</th>
                            <th>url</th>
                            <th>操作</th>
                          </tr>
                        </thead>
                        <tbody>
                          <foreach name="navtop" item="val">
                            <tr class="selected">
                              <td>{$val.nav_title}</td>
                              <td class="hidden-480">
                              <if condition="$val.nav_location eq 0">顶部</if>
                              <if condition="$val.nav_location eq 1">中间</if>
                              <if condition="$val.nav_location eq 2">底部</if>
                               </td>
                              <td class="hidden-480">{$val.nav_sort}</td>
                              <td><if condition="$val.nav_is_close eq 0">否<else />是</if></td>
                              <td><if condition="$val.nav_new_open eq 0">否<else />是</if></td>
                              <td>{$val.nav_url}</td>
                              <td><div class="visible-md visible-lg hidden-sm hidden-xs btn-group"> <a class="btn btn-xs btn-info" href="{:U('Admin/Setting/nav')}/id/{$val.nav_id}"> <i class="icon-edit bigger-120"></i> </a> <a class="btn btn-xs btn-danger" onClick="nav_del(this,{$val.nav_id})"> <i class="icon-trash bigger-120"></i> </a> </div></td>
                            </tr>
                          </foreach>
                        </tbody>
                      </table>
                    </div>
                    <div id="center" class="tab-pane <if condition="$nav.nav_location eq 1"> active</if>">
                      <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                        <thead>
                          <tr>
                            <th>导航名称</th>
                            <th class="hidden-480">位置</th>
                            <th class="hidden-480">排序</th>
                            <th>是否显示</th>
                            <th>是否新窗口</th>
                            <th>url</th>
                            <th>操作</th>
                          </tr>
                        </thead>
                        <tbody>
                          <foreach name="mintop" item="val">
                            <tr class="selected">
                              <td>{$val.nav_title}</td>
                              <td class="hidden-480">
                              <if condition="$val.nav_location eq 0">顶部</if>
                              <if condition="$val.nav_location eq 1">中间</if>
                              <if condition="$val.nav_location eq 2">底部</if>
                               </td>
                              <td class="hidden-480">{$val.nav_sort}</td>
                              <td><if condition="$val.nav_is_close eq 0">否<else />是</if></td>
                              <td><if condition="$val.nav_new_open eq 0">否<else />是</if></td>
                              <td>{$val.nav_url}</td>
                              <td><div class="visible-md visible-lg hidden-sm hidden-xs btn-group"> <a class="btn btn-xs btn-info" href="{:U('Admin/Setting/nav')}/id/{$val.nav_id}"> <i class="icon-edit bigger-120"></i> </a> <a class="btn btn-xs btn-danger" onClick="nav_del(this,{$val.nav_id})"> <i class="icon-trash bigger-120"></i> </a> </div></td>
                            </tr>
                          </foreach>
                        </tbody>
                      </table>
                    </div>
                    <div id="down" class="tab-pane <if condition="$nav.nav_location eq 2"> active </if>" >
                      <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                        <thead>
                          <tr>
                            <th>导航名称</th>
                            <th class="hidden-480">位置</th>
                            <th class="hidden-480">排序</th>
                            <th>是否显示</th>
                            <th>是否新窗口</th>
                            <th>url</th>
                            <th>操作</th>
                          </tr>
                        </thead>
                        <tbody>
                          <foreach name="downtop" item="val">
                            <tr class="selected">
                              <td>{$val.nav_title}</td>
                              <td class="hidden-480">
                              <if condition="$val.nav_location eq 0">顶部</if>
                              <if condition="$val.nav_location eq 1">中间</if>
                              <if condition="$val.nav_location eq 2">底部</if>
                               </td>
                              <td class="hidden-480">{$val.nav_sort}</td>
                              <td><if condition="$val.nav_is_close eq 0">否<else />是</if></td>
                              <td><if condition="$val.nav_new_open eq 0">否<else />是</if></td>
                              <td>{$val.nav_url}</td>
                              <td><div class="visible-md visible-lg hidden-sm hidden-xs btn-group"> <a class="btn btn-xs btn-info" href="{:U('Admin/Setting/nav')}/id/{$val.nav_id}"> <i class="icon-edit bigger-120"></i> </a> <a class="btn btn-xs btn-danger" onClick="nav_del(this,{$val.nav_id})"> <i class="icon-trash bigger-120"></i> </a> </div></td>
                            </tr>
                          </foreach>
                        </tbody>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <input type="hidden" value="{:U('Admin/Setting/nav_del')}" id="nav_del">
  <!-- /.row --> 
</div>
<!-- /.page-content --> 

<!-- /#ace-settings-container --> 
<!--[if !IE]> -->

		<script src="/Public/Admin/js/jquery-2.0.3.min.js"></script>

		<!-- <![endif]--> 

<!--[if IE]>
<script src="/Public/Admin/js/jquery-2.0.3.min.js"></script>
<![endif]--> 

<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='/Public/Admin/js/jquery-2.0.3.min.js'>"+"<"+"script>");
		</script>

		<!-- <![endif]--> 

<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='/Public/Admin/js/jquery-1.10.2.min.js'>"+"<"+"script>");
</script>
<![endif]--> 

<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='/Public/Admin/js/jquery.mobile.custom.min.js'>"+"<"+"script>");
		</script> 
<script src="/Public/Admin/js/bootstrap.min.js"></script> 
<script src="/Public/Admin/js/typeahead-bs2.min.js"></script> 

<!-- page specific plugin scripts --> 

<!--[if lte IE 8]>
		  <script src="/Public/Admin/js/excanvas.min.js"></script>
		<![endif]--> 

<!-- ace scripts --> 

<script src="/Public/Admin/js/ace-elements.min.js"></script> 
<script src="/Public/Admin/js/ace.min.js"></script> 
<script src="__ADMIN_JS__/jquery.validate.min.js"></script> 
<script src="__ADMIN_JS__/bootbox.js"></script> 
<script type="text/javascript">
			 
$(document).ready(function(){
                $('#id-input-file-2').ace_file_input({
					no_file:'没有选择文件',
					btn_choose:'选择',
					btn_change:'更改',
					droppable:false,
					onchange:null,
					thumbnail:false //| true | large
					//whitelist:'gif|png|jpg|jpeg'
 					//blacklist:'exe|php'
					//onchange:''
					//
				});

	
    $("#submitBtn").click(function(){ 
         $("#validation-form").submit();
    });
	$('#validation-form').validate({
		errorElement: 'div',
		errorClass: 'help-block',
		focusInvalid: false,
        rules : {
        	            nav_title: {
							required: true
 						},
						nav_location: {
							required: true
						},
 						adv_url: {
							required: true,
							url:true
						},
						nav_new_open: 'required',
						nav_is_close: 'required'
						 
        },
        messages : {
      		            nav_title: {
							required: "导航标题不能为空.",
 						},
						nav_location: {
							required: "导航位置不能为空.",
 						},
						adv_url: {
							required: "导航链接不能为空.",
							url: "请输入合法url"
						} ,
						site_open: "请选择是否新窗口状态",
						site_open: "请选择是否显示状态"
						 
        },
		 
			
					highlight: function (e) {
						$(e).closest('.form-group').removeClass('has-info').addClass('has-error');
					},
			
					success: function (e) {
						$(e).closest('.form-group').removeClass('has-error').addClass('has-info');
						$(e).remove();
					},
			
					errorPlacement: function (error, element) {
						if(element.is(':checkbox') || element.is(':radio')) {
							var controls = element.closest('div[class*="col-"]');
							if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
							else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
						}
						else if(element.is('.select2')) {
							error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
						}
						else if(element.is('.chosen-select')) {
							error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
						}
						else error.insertAfter(element.parent());
					},
			
					submitHandler: function (form) {
						$(form).ajaxSubmit();
			            var index = parent.layer.getFrameIndex(window.name);
			            //parent.$('.btn-refresh').click();
			            parent.layer.close(index);
					}
					 
    });
});
		</script> 
<script type="text/javascript">
     /*文章-删除*/
function nav_del(obj,id){
	  var host=$("#nav_del").val();
      bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定删除该banner?", function(result) {  
        if (result) {  
           $.ajax({
			url:host,
			type:"POST",
			dataType:"json",
			data:{id:id},
			success: function(s){
 				if(s.status == 1){
				$(obj).parents("tr").remove();
				bootbox.alert('删除成功');
				}else{
				bootbox.alert(s.info);	
					}
				}
			})
		
		 
        }  
      });  
 
}
</script>
</body>
</html>